<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
</ul>
<script>
    var lis=document.getElementsByTagName('li');
    for(var i=0;i<lis.length;++i){
        lis[i].onmouseover=over(i);

        lis[i].onmouseout=out(i);

    }
    function over(n){
        function f1(){
            lis[n].style.background="#eee";
        }
        return f1;
    }

    function out(n){
        function f2(){
            lis[n].style.background="#eee";
        }
        return f2;
    }
</script>
</body>
</html>